<%--
  Created by IntelliJ IDEA.
  User: wkk
  Date: 2022/5/3
  Time: 14:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="./js/jquery-3.4.1.min.js"></script>
<script src="./js/bootstrap.js" ></script>
<link rel="stylesheet" href="./css/bootstrap.css">
<body>

<button   onclick = "btn()" class="btn btn-primary">点击发送json请求</button>

<script>
    function btn(){
        let user = {id:1,username:"王",birthday:"2021-03-18 12:00:31",salary:11.48552}
        let str = JSON.stringify(user);
        $.ajax({
            url: "http://localhost:8080${pageContext.request.contextPath}/ajax/test1",
            type: "post",
            contentType: "application/json;charset=UTF-8",
            data: str,
            success: function (res){
                alert(res);
                console.log(res);
            }
        })
    }
</script>
</body>
</html>
